package com.siwei.mes.entity.experiment;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.config.UidUtils;
import com.siwei.mes.entity.erp.Phbhistory;
import com.siwei.mes.entity.erp.Rwdextra;
import com.siwei.mes.entity.erp.RwdextraPrintInfo;
import com.siwei.mes.enums.GenerateCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 开盘鉴定表(OpenAppraisal)实体类
 *
 * @author makejava
 * @since 2024-11-23 10:50:05
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_open_appraisal")
@ApiModel(value = "OpenAppraisal", description = "开盘鉴定表")
public class OpenAppraisal implements Serializable {
    private static final long serialVersionUID = -20512998409606248L;
    /**
     * 主键id
     */
    @Id
    @ApiModelProperty(value = "开盘鉴定表主键ID", name = "id")
    private Long id;
    /**
     * 记录编号
     */
    @Column(name = "appraisal_no")
    @ApiModelProperty(value = "记录编号", name = "appraisalNo")
    private String appraisalNo;
    /**
     * 台账编号 4位数,自增,每年清空一次
     */
    @Column(name = "ledger_no")
    @ApiModelProperty(value = "台账编号 4位数,自增,每年清空一次", name = "ledgerNo")
    private String ledgerNo;
    /**
     * 工程名称
     */
    @Column(name = "project_name")
    @ApiModelProperty(value = "工程名称", name = "projectName")
    private String projectName;
    /**
     * 配比编号
     */
    @Column(name = "proportion_phb")
    @ApiModelProperty(value = "配比编号", name = "proportionPhb")
    private String proportionPhb;
    /**
     * 年份
     */
    @Column(name = "year")
    @ApiModelProperty(value = "年份", name = "year")
    private String year;
    /**
     * 任务单id
     */
    @Column(name = "frwdh")
    @ApiModelProperty(value = "任务单id", name = "frwdh")
    private Integer frwdh;
    /**
     * 任务单号
     */
    @Column(name = "frwno")
    @ApiModelProperty(value = "任务单号", name = "frwno")
    private String frwno;
    /**
     * 车号
     */
    @Column(name = "car_no")
    @ApiModelProperty(value = "车号", name = "carNo")
    private String carNo;
    /**
     * 车牌号
     */
    @Column(name = "car_card")
    @ApiModelProperty(value = "车牌号", name = "carCard")
    private String carCard;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 开盘鉴定打印的json
     */
    @Column(name = "print_json")
    @ApiModelProperty(value = "开盘鉴定打印的json")
    private JSONObject printJson;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;

    @Transient
    @ApiModelProperty(value = "开盘鉴定打印的对象")
    private RwdextraPrintInfo rwdextraPrintInfo;

    @Transient
    @ApiModelProperty(value = "ERP配合比修改信息(小票生产日期最近一次)")
    private Phbhistory phbhistory;

    @Transient
    @ApiModelProperty(value = "任务单对象")
    private Rwdextra rwdextra;

    @Transient
    @ApiModelProperty(value = "年份", name = "year")
    private List<Integer> years;

    public OpenAppraisal init(boolean isCreate) {
        this.setUpdateTime(new Date());
        if (isCreate) {
            this.setCreateTime(new Date()).setIsDel(0)
                    .setAppraisalNo(UidUtils.genNo(GenerateCodeEnum.OPEN_APPRAISAL.getCode()))
                    .setLedgerNo(UidUtils.genNoNumber(GenerateCodeEnum.OPEN_APPRAISAL_LEDGER.getCode(), "%05d"));
            ;
        }
        return this;
    }
}
